<!DOCTYPE html>
<html>
<head>
<title>#{get 'title' /}</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

<link href="/../../../public/stylesheets/style_sheet.css"
	rel="stylesheet" type="text/css" />

<!--<script src="/../../../public/javascript/jquery.js"
	type="text/javascript"></script>
<script src="/../../../public/javascript/scripts.js"
	type="text/javascript"></script>-->

#{get 'moreStyles' /}
<link rel="shortcut icon" type="image/png"
	href="@{'/public/images/ninjaIcon.png'}">
<link rel="stylesheet"
	href="/../../../public/javascripts/jquery.jgrowl.css" type="text/css" />
<link rel="stylesheet"
	href="../../../public/stylesheets/blitzer/jquery-ui-1.8.13.custom.css"
	type="text/css" media="screen" />
<link rel="stylesheet"
	href="@{'/public/javascripts/fancybox/jquery.fancybox-1.3.4.css'}"
	type="text/css" media="screen" />
<script src="../../../public/javascripts/jquery-1.5.1.min.js"
	type="text/javascript"></script>






<!-- 3amleeen mashakel !!!!!!!!!!!!!!!!
	<script type="text/javascript" src="/../../../public/javascripts/jquery-1.4.2.js"></script>
            <script type="text/javascript" src=
            "../../../public/javascripts/jquery.ui.all.js" ></script>
        -->



<!-- JAVA SCRIPT PARTIOTION START -->

<script type="text/javascript">
	//plugin found on the internet
	function updateList() {

		//Adjust panel height
		$.fn.adjustPanel = function() {
			$(this).find("ul, .subpanel").css({
				'height' : 'auto'
			}); //Reset subpanel and ul height

			var windowHeight = $(window).height(); //Get the height of the browser viewport
			var panelsub = $(this).find(".subpanel").height(); //Get the height of subpanel
			var panelAdjust = windowHeight - 100; //Viewport height - 100px (Sets max height of subpanel)
			var ulAdjust = panelAdjust - 25; //Calculate ul size after adjusting sub-panel (27px is the height of the base panel)

			if (panelsub >= panelAdjust) { //If subpanel is taller than max height...
				$(this).find(".subpanel").css({
					'height' : panelAdjust
				}); //Adjust subpanel to max height
				$(this).find("ul").css({
					'height' : ulAdjust
				}); //Adjust subpanel ul to new size
			} else if (panelsub < panelAdjust) { //If subpanel is smaller than max height...
				$(this).find("ul").css({
					'height' : 'auto'
				}); //Set subpanel ul to auto (default size)
			}
		};

		//Execute function on load
		$("#chatpanel").adjustPanel(); //Run the adjustPanel function on #chatpanel
		$("#alertpanel").adjustPanel(); //Run the adjustPanel function on #alertpanel

		//Each time the viewport is adjusted/resized, execute the function
		$(window).resize(function() {
			$("#chatpanel").adjustPanel();
			$("#alertpanel").adjustPanel();
		});

		//Click event on Chat Panel + Alert Panel
		$("#chatpanel a:first, #alertpanel a:first").click(function() { //If clicked on the first link of #chatpanel and #alertpanel...
			if ($(this).next(".subpanel").is(':visible')) { //If subpanel is already active...
				$(this).next(".subpanel").hide(); //Hide active subpanel
				$("#footpanel li a").removeClass('active'); //Remove active class on the subpanel trigger
			} else { //if subpanel is not active...
				$(".subpanel").hide(); //Hide all subpanels
				$(this).next(".subpanel").toggle(); //Toggle the subpanel to make active
				$("#footpanel li a").removeClass('active'); //Remove active class on all subpanel trigger
				$(this).toggleClass('active'); //Toggle the active class on the subpanel trigger
			}
			return false; //Prevent browser jump to link anchor
		});

		//Click event outside of subpanel
		$(document).click(function() { //Click anywhere and...
			$(".subpanel").hide(); //hide subpanel
			$("#footpanel li a").removeClass('active'); //remove active class on subpanel trigger
		});
		$('.subpanel ul').click(function(e) {
			e.stopPropagation(); //Prevents the subpanel ul from closing on click
		});

		//Delete icons on Alert Panel
		$("#alertpanel li").hover(function() {
			$(this).find("a.delete").css({
				'visibility' : 'visible'
			}); //Show delete icon on hover
		}, function() {
			$(this).find("a.delete").css({
				'visibility' : 'hidden'
			}); //Hide delete icon on hover out
		});
	}
</script>

<script type="text/javascript">
	function showNotificationsNotification() {

		$.getJSON('@{usersController.DisplayNotificationPopID()}',

		{
			'userName' : "username"
		}, function(data) {
			if (data != null && data.result == "sizeNotEqualZero"
					&& data.NoNewNotification == "no") {

				$('#two').jGrowl(data.list);
                               // $('#one').jGrowl(data.list);


			} else {

				//alert("No Notifications available ");
                               
			}
		});
                  var t=setTimeout("showNotificationsNotification()",10000);
	}
</script>

<script type="text/javascript">
	function fillFriends() {
		$
				.getJSON(
						'@{UserProfile.getFriends()}',
						{},
						function(data) {
							document.getElementById("friendsListJava").innerHTML = data.friends;
						});
	}
</script>
<script type="text/javascript">
	function showNotificationsID() {

		$
				.getJSON(
						'@{usersController.DisplayNotificationSID()}',

						{
							'userName' : "username"
						},
						function(data) {
							if (data != null
									&& data.result == "sizeNotEqualZero") {
								var list = {};
								list = data.list.split("&&");

								var total = "<h3><span>&ndash; </span>Notifications</h3><ul><li class=\"view\"><a href=\"http://localhost:9000/\">View All</a></li>";
								//<p><a href='#' onclick=\"show_iDev('"+ innerList[0]+ "')\">"+ innerList[0]+ "</a> "+innerList[1]+"</p>

								for ( var i = 0; i < list.length - 1 && i < 5; i = i + 1) {

									var innerList = {};
									innerList = list[i].split(",,,");
									total += "<li><a href=\"#\" class=\"delete\">X</a><p>"
											+ innerList[0]
											+ " "
											+ innerList[1] + "</p></li>";

								}
								total += "</ul>";
								document.getElementById("notificationS").innerHTML = total;
								updateList()
							} else {
								document.getElementById("notificationS").innerHTML = "<h3><span>&ndash; </span>Notifications</h3><ul><li class=\"view\"><a href=\"http://localhost:9000/\">View All</a></li><li><p> No Notifications available</p></li></ul>";
						updateList()
                                                    }
						});
	}
</script>

<script type="text/javascript">
	var currrent = "";
	$(function() {
		$.getJSON("@{Application.getId()}", function(data) {
			current = data.res;
		});
		$('#devCanDivInOrg').hide();
		$('#createEntityDiv').hide();
		$('#createOrgDiv').hide();
		$('#createSubEntityDiv').hide();
		$('#deleteEntityDiv').hide();
		$('#orgRequestDiv').hide();
		$('#devRequestDiv').hide();
		$('#devCanDivInEnt').hide();
		javascript: fillTags();
		javascript: fillFriends();
		javascript: whoIsLoggedIn();
	});
	function whoIsLoggedIn() {
		var currentU = "";
		$
				.getJSON(
						"@{Application.getCurrentUser()}",
						function(data) {
							document.getElementById("whoIsLoggedIn").innerHTML = "<label style=\"background: #333 url('../../public/images/light.png') center center repeat-x; color: white; margin: 5px; padding: 5px 15px; text-decoration: none; border-radius: 4px; font-size: 14px; font-weight: bold; float: right;\">Welcome "
									+ data.result + "!</label>";
						});

	}

	function OnGoMenuFormLink(GoList) {
		var url = GoList.options[GoList.selectedIndex].value;
		//var target = GoList.options[GoList.selectedIndex].className;
		if (url == "CreateEn") {
			//prepare the data which is the organizations he can partiotion it
			document.getElementById("createEntityDiv").innerHTML = "";
			$
					.getJSON(
							'@{Application.getManagedOrganizations()}',
							{
								'id' : current
							},
							function(data) {
								if (data == null || data.length == 0) {
									alert("You arnot athurized to do that in any org :)");
								} else {
									
									var total = "<p><label>please choose one from your organizations</label><select id=\"selavorg\">"
									for ( var i = 0; i < data.length; i = i + 1) {
										total += "<option selected value="+data[i].id+">"
												+ data[i].name + "</option>"
									}
									total += "</select></p>";
									total += "<p><input type=\"text\" id=\"newEntName\"/></p>";
									total += "<p><a href='#' onclick=\"createEntity()\">submit</a></p>";
									document.getElementById("createEntityDiv").innerHTML = total;
									$('#createEntityDiv').toggle(1000);
									$('#devCanDivInOrg').hide(1000);
									$('#createSubEntityDiv').hide(1000);
									$('#deleteEntityDiv').hide(1000);
									$('#orgRequestDiv').hide(1000);
									$('#devRequestDiv').hide(1000);
									$('#devCanDivInEnt').hide(1000);
									$('#createOrgDiv').hide(1000);
								}
							});

		} else if (url == "CreateSub") {
			$('#createSubEntityDiv').hide(1000);
			document.getElementById("createSubEntityDiv").innerHTML = "";
			$
					.getJSON(
							'@{Application.getManagedEntities()}',
							{
								'id' : current
							},
							function(data) {
								if (data == null || data.length == 0) {
									alert("You don't manage any entity to add a sub entity in :)");
								} else {
									var total = "<p><label>please choose one from your organizations</label><select id=\"selavent\">"
									for ( var i = 0; i < data.length; i = i + 1) {
										total += "<option selected value="+data[i].id+">"
												+ data[i].name + "</option>"
									}
									total += "</select></p>";
									total += "<p><input type=\"text\" id=\"newSubEntName\"/></p>";
									total += "<p><a href='#' onclick=\"createSubEntity()\">submit</a></p>";
									document
											.getElementById("createSubEntityDiv").innerHTML = total;
									$('#createEntityDiv').hide(1000);
									$('#devCanDivInOrg').hide(1000);
									$('#createSubEntityDiv').toggle(1000);
									$('#deleteEntityDiv').hide(1000);
									$('#orgRequestDiv').hide(1000);
									$('#devRequestDiv').hide(1000);
									$('#devCanDivInEnt').hide(1000);
									$('#createOrgDiv').hide(1000);
								}
							});

		} else if (url == "DelEn") {
			$('#deleteEntityDiv').hide(1000);
			document.getElementById("deleteEntityDiv").innerHTML = "";
			$
					.getJSON(
							'@{Application.getManagedEntities()}',
							{
								'id' : current
							},
							function(data) {
								if (data == null || data.length == 0) {
									alert("You don't manage any entity to delete it :)");
								} else {
									var total = "<p><label>please choose one from your entities</label><select id=\"selavent2\">"
									for ( var i = 0; i < data.length; i = i + 1) {
										total += "<option selected value="+data[i].id+">"
												+ data[i].name + "</option>"
									}
									total += "</select></p>";
									total += "<p><a href='#' onclick=\"delEntity()\">submit</a></p>";
									document.getElementById("deleteEntityDiv").innerHTML = total;
									$('#devCanDivInOrg').hide(1000);
									$('#createEntityDiv').hide(1000);
									$('#createSubEntityDiv').hide(1000);
									$('#deleteEntityDiv').toggle(1000);
									$('#orgRequestDiv').hide(1000);
									$('#devRequestDiv').hide(1000);
									$('#devCanDivInEnt').hide(1000);
									$('#createOrgDiv').hide(1000);
								}
							});
		} else if (url == "CheckInviteOrg") {
			$('#orgRequestDiv').hide();

			$
                        .getJSON(
							"@{Application.getRequestsRecievedForMyOrgz()}",
							{
								'id' : current
							},
							function(data) {
								if (data == null || data.length == 0) {
									alert("No New requests sent to join your organizations or your managed Entities");
								} else {
									document.getElementById("orgRequestDiv").innerHTML = "";
									for ( var i = 0; i < data.length; i = i + 1) {
										document
												.getElementById("orgRequestDiv").innerHTML += "<p>"
												+ data[i].name
												+ "<a href='#' onclick = \"acceptReq('"
												+ data[i].id
												+ "')\"> ACCEPT </a>"
												+ "<a href='#' onclick = \"declineReq('"
												+ data[i].id
												+ "')\"> REJECT </a></p>";
									}
									$('#devCanDivInOrg').hide(1000);
									$('#createEntityDiv').hide(1000);
									$('#createSubEntityDiv').hide(1000);
									$('#deleteEntityDiv').hide(1000);
									$('#orgRequestDiv').toggle(1000);
									$('#devRequestDiv').hide(1000);
									$('#devCanDivInEnt').hide(1000);
									$('#createOrgDiv').hide(1000);
								}
							});
		} else if (url == "CheckInviteDev") {
			$('#devRequestDiv').hide();
			$
					.getJSON(
							"@{Application.getRequestsSentToIdeaDeveloper()}",
							{
								'devId' : current
							},
							function(data) {
								
								if (data == null || data.length == 0) {
									alert("No New requests has been sent to you");
								} else {
									document.getElementById("devRequestDiv").innerHTML = "";
									for ( var i = 0; i < data.length; i = i + 1) {
										document
												.getElementById("devRequestDiv").innerHTML += "<p>"
												+ data[i].name
												+ "<a href='#' onclick = \"acceptReqTwo('"
												+ data[i].id
												+ "')\"> ACCEPT </a>"
                                                                                                + "<a href='#' onclick = \"declineReqTwo('"
												+ data[i].id
												+ "')\"> REJECT </a></p>";
									}
									$('#devCanDivInOrg').hide(1000);
									$('#createEntityDiv').hide(1000);
									$('#createSubEntityDiv').hide(1000);
									$('#deleteEntityDiv').hide(1000);
									$('#orgRequestDiv').hide(1000);
									$('#devRequestDiv').toggle(1000);
									$('#devCanDivInEnt').hide(1000);
									$('#createOrgDiv').hide(1000);
								}
							});
		} else if (url == "InviteDevToEntity") {
			$('#devCanDivInEnt').hide(1000);
			document.getElementById("devCanDivInEnt").innerHTML = "";
			$
					.getJSON(
							'@{Application.getManagedEntities()}',
							{
								'id' : current
							},
							function(data) {
								if (data == null || data.length == 0) {
									alert("You don't manage any entity to join developers in :)");
								} else {
									//alert(data.length);
									var total = "<p><label>please choose one from your entities</label><select id=\"selavent3\">"
									for ( var i = 0; i < data.length; i = i + 1) {
										total += "<option selected value="+data[i].id+">"
												+ data[i].name + "</option>"
									}
									total += "</select></p>";
									total += "<div id='ideaDevelopers'></div>";
									total += "<p><a href='#' onclick=\"getDevCanReqInEnt()\">submit</a></p>";
									document.getElementById("devCanDivInEnt").innerHTML = total;
									$('#devCanDivInEnt').toggle(1000);
									$('#devCanDivInOrg').hide(1000);
									$('#createEntityDiv').hide(1000);
									$('#createSubEntityDiv').hide(1000);
									$('#deleteEntityDiv').hide(1000);
									$('#orgRequestDiv').hide(1000);
									$('#devRequestDiv').hide(1000);
									$('#createOrgDiv').hide(1000);
								}
							});

		} else if (url == "InviteDevToOrganization") {
			$('#devCanDivInOrg').hide(1000);
			document.getElementById("devCanDivInOrg").innerHTML = "";
			$
					.getJSON(
							'@{Application.getManagedOrganizations()}',
							{
								'id' : current
							},
							function(data) {
								if (data == null || data.length == 0) {
									alert("You don't manage any Organization to invite developers in :)");
								} else {
									var total = "<p><label>please choose one from your organizations</label><select id=\"selorg3\">"
									for ( var i = 0; i < data.length; i = i + 1) {
										total += "<option selected value="+data[i].id+">"
												+ data[i].name + "</option>"
									}
									total += "</select></p>";
									total += "<div id='ideaDevelopers1'></div>";
									total += "<p><a href='#' onclick=\"getDevCanReqInOrg()\">submit</a></p>";
									document.getElementById("devCanDivInOrg").innerHTML = total;
									$('#devCanDivInOrg').toggle(1000);
									$('#devCanDivInEnt').hide(1000);
									$('#createEntityDiv').hide(1000);
									$('#createSubEntityDiv').hide(1000);
									$('#deleteEntityDiv').hide(1000);
									$('#orgRequestDiv').hide(1000);
									$('#devRequestDiv').hide(1000);
									$('#createOrgDiv').hide(1000);
								}
							});
		} else if (url == "CreateOrg") {
			var total = "<p><label>Enter the name : </label><input id=\"orgNameText\" type='text'/></p>";
			total += "<p><label>Enter the Privacy : </label><select id='orgType'><option value = \"public\">Public</option><option value = \"private\">Private</option><option value = \"secret\">Secret</option></select></p>";
			total += "<p><label>Enter the description : </label><input id=\"orgDescText\" type='text'/></p>";
			total += "<p><a href='#' onclick=\"createOrganization()\">Submit</a></p>"
			document.getElementById('createOrgDiv').innerHTML = total;
			$('#createOrgDiv').toggle(1000);
			$('#devCanDivInOrg').hide(1000);
			$('#devCanDivInEnt').hide(1000);
			$('#createEntityDiv').hide(1000);
			$('#createSubEntityDiv').hide(1000);
			$('#deleteEntityDiv').hide(1000);
			$('#orgRequestDiv').hide(1000);
			$('#devRequestDiv').hide(1000);
		}
	}
	//createOrganization(long devId, String orgName, String description, String type) {
	function createOrganization() {
		var name = document.getElementById("orgNameText").value;
		var desc = document.getElementById("orgDescText").value;
		var type = document.getElementById('orgType').options[document
				.getElementById('orgType').selectedIndex].value
		if (name.length < 3 || desc.length < 3) {
			alert("Name and Description are required and with length of minimum 3 :)");
		} else {
			$.getJSON('@{Application.createOrganization()}', {
				'devId' : current,
				'orgName' : name,
				'description' : desc,
				'type' : type
			}, function(data) {
				alert(data.res);
				if (data.res == "Done Adding") {
					$('#createOrgDiv').hide(1000);
				}
			});

		}

	}
        function declineReqTwo(reqId){
        $.getJSON("@{Application.declineRequest()}",{'reqId':reqId},function(data){
            alert(data.res);
        $('#devRequestDiv').hide();
			$
					.getJSON(
							"@{Application.getRequestsSentToIdeaDeveloper()}",
							{
								'devId' : current
							},
							function(data) {
								
								if (data == null || data.length == 0) {
									alert("No New requests has been sent to you");
								} else {
									document.getElementById("devRequestDiv").innerHTML = "";
									for ( var i = 0; i < data.length; i = i + 1) {
										document
												.getElementById("devRequestDiv").innerHTML += "<p>"
												+ data[i].name
												+ "<a href='#' onclick = \"acceptReqTwo('"
												+ data[i].id
												+ "')\"> ACCEPT </a>"
                                                                                                + "<a href='#' onclick = \"declineReqTwo('"
												+ data[i].id
												+ "')\"> REJECT </a></p>";
									}
									$('#devCanDivInOrg').hide(1000);
									$('#createEntityDiv').hide(1000);
									$('#createSubEntityDiv').hide(1000);
									$('#deleteEntityDiv').hide(1000);
									$('#orgRequestDiv').hide(1000);
									$('#devRequestDiv').toggle(1000);
									$('#devCanDivInEnt').hide(1000);
									$('#createOrgDiv').hide(1000);
								}
							});
        });
        }

         function acceptReqTwo(reqId){
        $.getJSON("@{Application.acceptRequest()}",{'reqId':reqId},function(data){
            alert(data.res);
        $('#devRequestDiv').hide();
			$
					.getJSON(
							"@{Application.getRequestsSentToIdeaDeveloper()}",
							{
								'devId' : current
							},
							function(data) {

								if (data == null || data.length == 0) {
									alert("No New requests has been sent to you");
								} else {
									document.getElementById("devRequestDiv").innerHTML = "";
									for ( var i = 0; i < data.length; i = i + 1) {
										document
												.getElementById("devRequestDiv").innerHTML += "<p>"
												+ data[i].name
												+ "<a href='#' onclick = \"acceptReqTwo('"
												+ data[i].id
												+ "')\"> ACCEPT </a>"
                                                                                                + "<a href='#' onclick = \"declineReqTwo('"
												+ data[i].id
												+ "')\"> REJECT </a></p>";
									}
									$('#devCanDivInOrg').hide(1000);
									$('#createEntityDiv').hide(1000);
									$('#createSubEntityDiv').hide(1000);
									$('#deleteEntityDiv').hide(1000);
									$('#orgRequestDiv').hide(1000);
									$('#devRequestDiv').toggle(1000);
									$('#devCanDivInEnt').hide(1000);
									$('#createOrgDiv').hide(1000);
								}
							});
        });
        }
        function declineReq(reqId){
        $.getJSON("@{Application.declineRequest()}",{'reqId':reqId},function(data){
            alert(data.res);
            $('#orgRequestDiv').hide();

			$
                        .getJSON(
							"@{Application.getRequestsRecievedForMyOrgz()}",
							{
								'id' : current
							},
							function(data) {
								if (data == null || data.length == 0) {
									alert("No New requests sent to you");
								} else {
									document.getElementById("orgRequestDiv").innerHTML = "";
									for ( var i = 0; i < data.length; i = i + 1) {
										document
												.getElementById("orgRequestDiv").innerHTML += "<p>"
												+ data[i].name
												+ "<a href='#' onclick = \"acceptReqTwo('"
												+ data[i].id
												+ "')\"> ACCEPT </a>"
												+ "<a href='#' onclick = \"declineReqTwo('"
												+ data[i].id
												+ "')\"> REJECT </a></p>";
									}
									$('#devCanDivInOrg').hide(1000);
									$('#createEntityDiv').hide(1000);
									$('#createSubEntityDiv').hide(1000);
									$('#deleteEntityDiv').hide(1000);
									$('#orgRequestDiv').hide(1000);
									$('#devRequestDiv').toggle(1000);
									$('#devCanDivInEnt').hide(1000);
									$('#createOrgDiv').hide(1000);
								}
							});
        });
        }
        
        function declineReq(reqId){
        $.getJSON("@{Application.declineRequest()}",{'reqId':reqId},function(data){
            alert(data.res);
            $('#orgRequestDiv').hide();

			$
                        .getJSON(
							"@{Application.getRequestsRecievedForMyOrgz()}",
							{
								'id' : current
							},
							function(data) {
								if (data == null || data.length == 0) {
									alert("No New requests sent to join your organizations or your managed Entities");
								} else {
									document.getElementById("orgRequestDiv").innerHTML = "";
									for ( var i = 0; i < data.length; i = i + 1) {
										document
												.getElementById("orgRequestDiv").innerHTML += "<p>"
												+ data[i].name
												+ "<a href='#' onclick = \"acceptReq('"
												+ data[i].id
												+ "')\"> ACCEPT </a>"
												+ "<a href='#' onclick = \"declineReq('"
												+ data[i].id
												+ "')\"> REJECT </a></p>";
									}
									$('#devCanDivInOrg').hide(1000);
									$('#createEntityDiv').hide(1000);
									$('#createSubEntityDiv').hide(1000);
									$('#deleteEntityDiv').hide(1000);
									$('#orgRequestDiv').toggle(1000);
									$('#devRequestDiv').hide(1000);
									$('#devCanDivInEnt').hide(1000);
									$('#createOrgDiv').hide(1000);
								}
							});
        });
        }
	function getDevCanReqInOrg() {
		var entId = document.getElementById('selorg3').options[document
				.getElementById('selorg3').selectedIndex].value
		document.getElementById('ideaDevelopers1').innerHtml = "";
		$('#ideaDevelopers1').hide(100);
		$
				.getJSON(
						"@{Application.getCanRequestIdeaDevelopersToOrganization()}",
						{
							'orgId' : entId
						},
						function(data) {
							if (data == null || data.length == 0) {
								alert("There are no developers you can invite to this organization");
							} else {
								var total = "";
								total += "<p><select id='orgToDevType' ><option selected value='JoinOrgFromOrgToDev'>Invite As A member</option><option value='JoinIdeaDeveloper'>Invite As An Organization Lead</option></select></p>";
								for ( var i = 0; i < data.length; i = i + 1) {
									if (data[i].id == -1) {
										total += "<p>" + data[i].name + "</p>";
									} else {
										total += "<p>"
												+ data[i].name
												+ " <a href='#' onclick=\"requestDeveloperInOrganization('"
												+ data[i].id + "','" + entId
												+ "')\">Invite</a></p>";
									}
								}
								document.getElementById("ideaDevelopers1").innerHTML = total;
								$('#ideaDevelopers1').toggle(500);
							}
						});
	}
	


            
            function getDevCanReqInOrg() {
               var entId = document.getElementById('selorg3').options[document
                    .getElementById('selorg3').selectedIndex].value
                document.getElementById('ideaDevelopers1').innerHtml = "";
                $('#ideaDevelopers1').hide(100);
                /*$
                .getJSON(
                "@{Application.getCanRequestIdeaDevelopersToOrganization()}",
                {
                    'orgId' : entId
                },
                function(data) {
                    if (data == null || data.length == 0) {
                        alert("There are no developers you can invite to this organization");
                    } else {
                        var total = "";
                               total += "<p><select id='orgToDevType' ><option selected value='JoinOrgFromOrgToDev'>Invite As A member</option><option value='JoinIdeaDeveloper'>Invite As An Organization Lead</option></select></p>";
                        for ( var i = 0; i < data.length; i = i + 1) {
                            if (data[i].id == -1) {
                                total += "<p>" + data[i].name + "</p>";
                            } else {
                                total += "<p>"
                                    + data[i].name
                                    + " <a href='#' onclick=\"requestDeveloperInOrganization('"
                                    + data[i].id + "','" + entId
                                    + "')\">Invite</a></p>";
                            }
                        }
             )};}*/
                        document.getElementById("ideaDevelopers1").innerHTML = "<p><select id='orgToDevType' ><option selected value='JoinOrgFromOrgToDev'>Invite As A member</option><option value='JoinIdeaDeveloper'>Invite As An Organization Lead</option></select></p>";
                        document.getElementById("ideaDevelopers1").innerHTML += "<p><input type=\"text\" id=\"usertoinvite\"onkeyup=\"javascript:getTags(document.getElementById('usertoinvite').value);\"/>";
                        document.getElementById("ideaDevelopers1").innerHTML += "<a href='#' onclick=\"requestDeveloperInOrganization('"+ document.getElementById('usertoinvite').value + "','" + entId+ "')\">Invite</a></p>";
                        $('#ideaDevelopers1').toggle(500);
                    }
                
            
            function requestDeveloperInOrganization(devId, entId) {
                var checkName = document.getElementById("usertoinvite").value;
                var type = document.getElementById('orgToDevType').options[document.getElementById('orgToDevType').selectedIndex].value
                $.getJSON("@{Application.requestIdeaDeveloperToOrganization()}", {
                    'devName' : checkName,
                    'orgId' : entId,
                    'type'  : type
                }, function(data) {
                    alert(data.res);
                    getDevCanReqInOrg();
                });
            }

	    function getDevCanReqInEnt() {
                var entId = document.getElementById('selavent3').options[document
                    .getElementById('selavent3').selectedIndex].value
                document.getElementById('ideaDevelopers').innerHtml = "";
                $('#ideaDevelopers').hide(100);
             /*   $
                .getJSON(
                "@{Application.getCanRequestIdeaDevelopersToEntity()}",
                {
                    'entId' : entId
                },
                function(data) {
                    if (data == null || data.length == 0) {
                        alert("There are no developers you can invite to this entity");
                    } else {
                        var total = "";
                        total += 
                        for ( var i = 0; i < data.length; i = i + 1) {
                            if (data[i].id == -1) {
                                total += "<p>" + data[i].name + "</p>";
                            } else {
                                total += "<p>"
                                    + data[i].name
                                    + " <a href='#' onclick=\"requestDeveloperInEntity('"
                                    + data[i].id + "','" + entId
                                    + "')\">Invite</a></p>";*/
              document.getElementById("ideaDevelopers").innerHTML = "<p><select id='entToDevType' ><option selected value='JoinEntFromEntToDev'>Invite As A member</option><option value='JoinIdeaDeveloper'>Invite As An Organizer</option></select></p>";
               document.getElementById("ideaDevelopers").innerHTML += "<p><input type=\"text\" id=\"usertoinvite2\"onkeyup=\"javascript:getTags2(document.getElementById('usertoinvite2').value);\"/>";
               document.getElementById("ideaDevelopers").innerHTML += "<a href='#' onclick=\"requestDeveloperInEntity('"+ document.getElementById('usertoinvite2').value + "','" + entId+ "')\">Invite</a></p>";
                $('#ideaDevelopers').toggle(500);

							}
						
	

	function requestDeveloperInEntity(devId, entId) {
		var type = document.getElementById('entToDevType').options[document
				.getElementById('entToDevType').selectedIndex].value
                            var checkName = document.getElementById("usertoinvite2").value;
		$.getJSON("@{Application.requestIdeaDeveloperToEntity()}", {
			'devName' : checkName,
			'entId' : entId,
			'type' : type
		}, function(data) {
			alert(data.res);
			getDevCanReqInEnt();
		});
	}


	function createEntity() {
		var orgid = document.getElementById('selavorg').options[document
				.getElementById('selavorg').selectedIndex].value
		
		if (document.getElementById("newEntName").value.length < 3) {
			alert('name req and atleast 3');
		} else {
			//public static void addEntity(String entityName, long orgId, long ideaDeveloper) {
			$.getJSON('@{Application.addEntity()}', {
				'entityName' : document.getElementById("newEntName").value,
				'orgId' : orgid,
				'ideaDeveloper' : current
			}, function(data) {
				alert(data.res);
				if (data.res == "Done Adding") {
					$('#createEntityDiv').toggle(1000);
				}
			});
		}


                    }
             
             
            

	
	//public static void addSubEntity(String entityName, long entId, long ideaDeveloper)
	function createSubEntity() {
		if (document.getElementById("newSubEntName").value.length < 3) {
			alert('name req and atleast 3');
		} else {
			var orgid = document.getElementById('selavent').options[document
					.getElementById('selavent').selectedIndex].value
			$.getJSON('@{Application.addSubEntity()}', {
				'entityName' : document.getElementById("newSubEntName").value,
				'entId' : orgid,
				'ideaDeveloper' : current
			}, function(data) {
				alert(data.res);
				if (data.res == "Done Adding") {
					$('#createSubEntityDiv').hide(1000);
				}
			});
		}
	}
	//public static void deleteEntity(long entId, long ideaDeveloper)
	function delEntity() {
		var orgid = document.getElementById('selavent2').options[document
				.getElementById('selavent2').selectedIndex].value;
		$.getJSON('@{Application.deleteEntity()}', {
			'entId' : orgid,
			'ideaDeveloper' : current
		}, function(data) {
			alert(data.res)
			if (data.res == "DONE") {
				$('#deleteEntityDiv').hide(1000);
			}
		});
	}
             
            function acceptReq(reqId) {
                $.getJSON("@{Application.acceptRequest()}", {
                    'reqId' : reqId
                }, function(data) {
                    $('#orgRequestDiv').hide();
                    alert(data.res);
                    $
                        .getJSON(
							"@{Application.getRequestsRecievedForMyOrgz()}",
							{
								'id' : current
							},
							function(data) {
								if (data == null || data.length == 0) {
									alert("No New requests sent to join your organizations or your managed Entities");
								} else {
									document.getElementById("orgRequestDiv").innerHTML = "";
									for ( var i = 0; i < data.length; i = i + 1) {
										document
												.getElementById("orgRequestDiv").innerHTML += "<p>"
												+ data[i].name
												+ "<a href='#' onclick = \"acceptReq('"
												+ data[i].id
												+ "')\"> ACCEPT </a>"
												+ "<a href='#' onclick = \"declineReq('"
												+ data[i].id
												+ "')\"> REJECT </a></p>";
									}
									$('#devCanDivInOrg').hide(1000);
									$('#createEntityDiv').hide(1000);
									$('#createSubEntityDiv').hide(1000);
									$('#deleteEntityDiv').hide(1000);
									$('#orgRequestDiv').toggle(1000);
									$('#devRequestDiv').hide(1000);
									$('#devCanDivInEnt').hide(1000);
									$('#createOrgDiv').hide(1000);
								}
							});
                });
            }

</script>

<script type="text/javascript">
	$(document).ready(function() {
		$(".frame").fancybox({

			'width' : '75%',

			'height' : '75%',

			'autoScale' : true,

			'transitionIn' : 'none',

			'transitionOut' : 'none',

			'type' : 'iframe'
                });
$(".frameNoRefresh").fancybox({

			'width' : '100%',

			'height' : '100%',

			'autoScale' : true,

			'transitionIn' : 'none',

			'transitionOut' : 'none',

			'type' : 'iframe'





		});
updateList()
communityCounter()
typeOfMe()
showNotificationsNotification()
	});

	function getTagsgh(search) {

		if (search != "") {
			$(function() {
				$.getJSON('@{QuickSearchRendering.autoComplete()}', {
					'search' : search
				}, function(data) {
					$("#searchMain").autocomplete({
						source : data.tags.split("&")
					});
				});

			});
		}
	}
</script>

<script type="text/javascript">
	function fillTags() {
		$
				.getJSON(
						'@{BrowseController.browseTags()}',
						function(data) {
							var tags = "";
							if (data.tagList != null) {
								var list = data.tagList.split('&&');
								for ( var i = 0; i < list.length - 1; i = i + 1) {
									tags += "<a href=\"@{BrowseController.TagView()}?tagToRenderName="
											+ list[i]
											+ "\">"
											+ list[i]
											+ "</a>"
								}
								document.getElementById('testTagCloud').innerHTML = tags;
								$('#testTagCloud').tagCloud();
							}
						});
	}
	function reshffule() {
		$.getJSON('@{IdeaDeveloperFunctions.reshuffle()}', {
			'type' : 'idea'
		},
		function(data) {
			var x = data.res;
			//	window.location = "@{TopicIdeaController.checkAuthorizationToViewIdea("+y+")}"
			window.location = "/TopicIdeaController/checkAuthorizationToViewIdea?ideaId="+x
		}, 'json')

	}
</script>
</head>
<body>
	<div id="container">

		<div id="header">
			<h1>
				<a href="/">MEGASOFT</a>
			</h1>
			<h2>Software ninjas</h2>
          

			<!-- <a href=""
				style="background: #333 url('../../public/images/light.png') center center repeat-x; color: white; margin: 5px; padding: 5px 15px; text-decoration: none; border-radius: 4px; font-size: 14px; font-weight: bold; float: right;">Sign
				Up</a> <a href=""
				style="background: #B22222 url('../../public/images/light.png') center center repeat-x; color: white; margin: 5px; padding: 5px 15px; text-decoration: none; border-radius: 4px; font-size: 14px; font-weight: bold; float: right;">Sign
				In</a> -->
			<div id="whoIsLoggedIn">

                        </div>

			<form>
				<input type="button" value="Back to Previous Page"
					onClick="javascript: history.go(-1)"
					style="background: #B22222 url('../../public/images/light.png') center center repeat-x; color: white; margin: 5px; padding: 5px 15px; text-decoration: none; border-radius: 4px; font-size: 14px; font-weight: bold; float: right;">
			</form>
			<div class="clear"></div>
		</div>
		<div id="nav">
			<ul>

                            
				<li><a href="@{UserProfile.SelfUserProfile()}">Home</a></li>
				<li><a href="@{BrowseController.BrowseOrganizations()}">organizations</a>
				</li>
				<li><a href="@{BrowseController.BrowseEntities()}">Entities</a>
				</li>
				<li><a href="@{BrowseController.BrowseTopics()}">Topics</a></li>

				<li><a href="@{BrowseController.BrowseIdeasPage()}">ideas</a></li>
				<li><a href="@{BrowseController.BrowseAll()}">Browse all</a>
				</li>
				
				<li><a href="#" onclick="javascript:reshffule()"
					title="shuffle">goCrazy</a></li>
				<li><a href="@{AdvancedSearchController.AdvancedSearchView()}">Advanced
						Search</a>
				</li>
				<!--<li><a href="#">About</a>-->

				<li><a href="@{Secure.logout()}" title="logout">Logout</a>
				<li class="nav-search">
					<form name="searchFormMain" method="get" class="searchform"
						action="@{QuickSearchRendering.searchOnClickSearchButton()}"
						onsubmit="return validate_formMain ( );">
						<p>
							<input type="text" id="searchMain" size="24" value=""
								name="search" class="s"
								onkeyup="javascript:getTagsgh(document.searchFormMain.searchMain.value);" />
							<!--                                                        <select name="filter" class="s">
								<option value="All">All</option>
								<option value="IdeaDevelopers">IdeaDevelopers</option>
								<option value="Tags">Tags</option>
								<option value="Organizations">Organizations</option>
								<option value="Entities">Entities</option>
								<option value="ActionPlans">ActionPlans</option>
								<option value="TopicsIdeas">Topic&Ideas</option>
							</select> -->
							<input type="submit" id="submitMain" name="submit"
								class="searchsubmit formbutton" value="Search" />

						</p>

					</form>
				</li>

			</ul>
		</div>


		<div>
			<form name="GoMenuForm0" action="">
				<select id="GoMenu" name="GoMenu"
					style="left: 1px; top: 1px; width: 149px; height: 30px; font-family: 'Courier New'; font-size: 13px;"
					onchange="OnGoMenuFormLink(this)">

					<option selected>Select a link</option>
					<option class="_self" value="CreateOrg">Create
						Organization</option>
					<option class="_self" value="CreateEn">Create Entity</option>
					<option class="_self" value="CreateSub">Create Sub Entity</option>
					<option class="_self" value="DelEn">Delete Entity</option>
					<option class="_self" value="CheckInviteOrg">Check
						Invitations Sent To One Of your Organizations Or Entities</option>

					<option class="_self" value="CheckInviteDev">Check
						Invitations Sent To you by Organizations Or Entities</option>
					<option class="_self" value="InviteDevToEntity">Invite
						Idea Developer to One Of your Entities</option>
					<option class="_self" value="InviteDevToOrganization">
						Invite Idea Developer to One Of your Organizations</option>
				</select>

			</form>
				<script type="text/javascript">
			function typeOfMe() {
				$.getJSON ('@{Application.typeOfMe()}',{},
						function (data){
						document.getElementById("Type").innerHTML = " , Your Type :" + data.type;
				})
				}
			</script>

			<script type="text/javascript">
				function communityCounter() {
					$
							.getJSON(
									'@{Application.communityCounter()}',
									{},
									function(data) {

										//alert(data.Counter);
										document.getElementById("Counter").innerHTML = "Community Counter : "
												+ data.Counter;

									})
				}
				
				
			</script>
		


		</div>
		<br />
		<div id = "Type" style ="float: right;">type </div>
		<div id="Counter" style="float: right;">counter</div>
		
		<div id="createOrgDiv"></div>

		<div id="createEntityDiv"></div>

		<div id="createSubEntityDiv"></div>

		<div id="deleteEntityDiv"></div>

		<div id="orgRequestDiv"></div>

		<div id="devRequestDiv"></div>

		<div id="devCanDivInEnt"></div>

		<div id="devCanDivInOrg"></div>

                



		<div id="page-intro"></div>
		<div id="body">
			<div id="footerplacement"
				style="height: 328px; width: 0px; float: right;"></div>
			#{doLayout /}
			  <div class="sidebar">
            <ul>
                <li>
                	<h4>Tag Cloud</h4>
					<div id="testTagCloud"
						style="position: relative; width: 300px; height: 200px; float: right;"></div>

					
                 </li>
                    </ul>

        </div>

			<div class="clear"></div>
		</div>
	</div>
	<!-- Notification bar  start here -->
	<div id="footpanel">

		<ul id="mainpanel">
			<li><a href="#" class="profile">View Profile <small>View
						Profile</small> </a></li>
			<li><a href="#" class="editprofile">Edit Profile <small>Edit
						Profile</small> </a></li>
			<li><a href="#" class="contacts">Contacts <small>Contacts</small>
			</a></li>

			<li><a href="#" class="messages">Messages (10) <small>Messages</small>
			</a></li>
			<li><a href="#" class="playlist">Play List <small>Play
						List</small> </a></li>
			<li><a href="#" class="videos">Videos <small>Videos</small>
			</a></li>

			
			<li id="alertpanel"><a href="#"
				onClick="javascript:showNotificationsID()" class="alerts">Alerts</a>
				<div id="notificationS" class="subpanel"></div></li>
			<li id="chatpanel"><a href="#" class="chat"
				onClick="javascript:updateList()">Friends </a>
				<div class="subpanel">
					<h3>
						<span>&ndash; </span>Friends
					</h3>
					<div id="friendsListJava"></div>

				</div></li>
		</ul>
	</div>
	<div id="two" class="jGrowl bottom-left">
		<div class="jGrowl-notification"></div>
	</div>
        <div id="one" class="center">
		<div class="jGrowl-notificationC"></div>
	</div>

	<!-- Notification bar  end here -->
	<div id="footer">
		<p>&copy; Megasoft 2011. Website Design by alot of PPL isA</p>



	</div>

	<script type="text/javascript">
		function validate_formMain() {
			valid = true;

			if (document.searchFormMain.searchMain.value == "" || document.searchFormMain.searchMain.value == " ") {
				alert("Please fill in the word to search for");
				valid = false;
			}


                return valid;
            }


        	function getTags(search) {
		if (search != "") {
				$.getJSON('@{Application.getCanRequestIdeaDevelopersToOrganization()}', {
					'orgId' : document.getElementById('selorg3').options[document.getElementById('selorg3').selectedIndex].value
				}, function(data) {
                                        $("#usertoinvite").autocomplete({
						source : data.result.split("&")
					});
				});

			
		}
	}

        function getTags2(search) {
		if (search != "") {
				$.getJSON('@{Application.getCanRequestIdeaDevelopersToEntity()}', {
					'entId' : document.getElementById('selavent3').options[document.getElementById('selavent3').selectedIndex].value
				}, function(data) {
                                        $("#usertoinvite2").autocomplete({
						source : data.result.split("&")
				 	});
				});


		}
	}

    </script>


      

	<script type="text/javascript"
		src="../../../public/javascripts/jquery.js"></script>
	<script type="text/javascript"
		src="/../../../public/javascripts/jquery.jgrowl.js"></script>
	<script type="text/javascript"
		src="../../../public/javascripts/jquery.tagcloud.min.js"></script>
	<script type="text/javascript"
		src="@{'/public/javascripts/fancybox/jquery.fancybox-1.3.4.pack.js'}"></script>
	<script
		src="../../../public/javascripts/jquery-ui-1.8.13.custom.min.js"
		type="text/javascript"></script>

</body>
</html>
